<template>
<div class="documentMember-declaring-customsVue">
  <el-tabs v-model="tabValue" @tab-click="documentProcessChoose">
    <el-tab-pane label="货运委托书" name="1">
      <letterOfDeliveryVue :bus="bus" @fromLD="updateData" :editable="editable" :datas="saveData.documentprocess_cc_letterOfDelivery"></letterOfDeliveryVue>
    </el-tab-pane>
    <el-tab-pane label="报关发票" name="2">
      <customsDeclarationInvoiceVue :bus="bus" @fromCI="updateData" :editable="editable"   :datas="saveData.documentprocess_cc_customsDeclarationInvoice"></customsDeclarationInvoiceVue>
    </el-tab-pane>
    <el-tab-pane label="报关箱单" name="3">
      <customsDeclarationBoxVue :bus="bus" @fromCB="updateData"  :editable="editable"   :datas="saveData.documentprocess_cc_customsDeclarationBox"></customsDeclarationBoxVue>
    </el-tab-pane>
    <el-tab-pane label="报关合同&委托书" name="4">
      <customsDeclarationContractVue  :bus="bus" @fromCC="updateData"  :editable="editable"  :datas="saveData.documentprocess_cc_customsDeclarationContract" ></customsDeclarationContractVue>
    </el-tab-pane>
    <el-tab-pane label="报关单" name="5">
      <declarationFormVue :bus="bus"  @fromDF="updateData"  :editable="editable"  :datas="saveData.documentprocess_cc_declarationForm" ></declarationFormVue>
    </el-tab-pane>
    <el-tab-pane label="申报要素" name="6">
      <declarationElementsVue :bus="bus"  :editable="editable"  @fromDE="updateData"   :datas="saveData.documentprocess_cc_declarationElements"></declarationElementsVue>
    </el-tab-pane>
  </el-tabs>
</div>
</template>

<script>
import letterOfDeliveryVue from './components/letterOfDeliveryVue.vue'
import customsDeclarationInvoiceVue from './components/customsDeclarationInvoiceVue.vue'
import customsDeclarationBoxVue from './components/customsDeclarationBoxVue.vue'
import customsDeclarationContractVue from './components/customsDeclarationContractVue.vue'
import declarationFormVue from './components/declarationFormVue.vue'
import declarationElementsVue from './components/declarationElementsVue.vue'



export default {

  created(){
    this.allData = _.cloneDeep(this.saveData);
  },
  mounted(){

  },
  updated(){
  },
  components: {
    letterOfDeliveryVue,
    customsDeclarationInvoiceVue,
    customsDeclarationBoxVue,
    customsDeclarationContractVue,
    declarationFormVue,
    declarationElementsVue
  },
  data() {
    return {
      saveData: {
          //货运委托书
          documentprocess_cc_letterOfDelivery: {
            id: '',
            formInstId: '',
            attachedFiles: [], //附件
            documentprocess_cc_lod_from: '', //
            documentprocess_cc_lod_to: '',
            documentprocess_cc_lod_fax: '', //货代fax
            documentprocess_cc_lod_transport: '', //运输
            documentprocess_cc_lod_contractNO: '', //合同编号
            documentprocess_cc_lod_consignee: '', //收货人
            documentprocess_cc_lod_caddress: '', //收货地址
            documentprocess_cc_lod_ctel: '', //收货电话
            documentprocess_cc_lod_seafreightCH: '预付', //海洋运费 中文
            documentprocess_cc_lod_seafreightEN: 'PREPAID', //海洋运费 英文
            documentprocess_cc_lod_loadPort: '', //起运港
            documentprocess_cc_lod_destPort: '', //目的港
            documentprocess_cc_lod_containers: '', //集装箱配数
            documentprocess_cc_lod_shipDate: '', //装期
            documentprocess_cc_lod_shipMarks: '', //标记码
            documentprocess_cc_lod_numbers: '', //件数
            documentprocess_cc_lod_products: '', //产品名称
            documentprocess_cc_lod_weight: '', //毛重
            documentprocess_cc_lod_size: '', //尺寸
            documentprocess_cc_lod_tradeTerms: '', //交易方式
            documentprocess_cc_lod_doorToDoor: '', //门对门地址
            documentprocess_cc_lod_entry: '', //货物进仓
            documentprocess_cc_lod_signer: '', //签名
            documentprocess_cc_lod_backAddress: '', //退单地址
            documentprocess_cc_lod_rise: '', //开票抬头
            documentprocess_cc_lod_contact: '', //联系人
            documentprocess_cc_lod_contactTel: '', //联系电话
            documentprocess_cc_lod_contactFax: '', //传真
            documentprocess_cc_lod_date: '', //订单日期
          },

          //报关发票
          documentprocess_cc_customsDeclarationInvoice: {
            id: '',
            formInstId: '',
            attachedFiles: [], //附件
            documentprocess_cc_cdi_toName: '', //买方
            documentprocess_cc_cdi_toAdd: '', //买方地址
            documentprocess_cc_cdi_toTel: '', //买方电话
            documentprocess_cc_cdi_invoiceNO: '', //发票编号
            documentprocess_cc_cdi_invoiceDate: '', //发票日期
            documentprocess_cc_cdi_fromPort: '', //出发港
            documentprocess_cc_cdi_toPort: '', //目的港
            documentprocess_cc_cdi_shipDate: '', //装期
            documentprocess_cc_cdi_transport: '', //运输方式
            documentprocess_cc_cdi_payTerms: 'BY T/T', //付款方式
            documentprocess_cc_cdi_tradeTerms: '', //交易方式
            documentprocess_cc_cdi_currencyValue: '人民币', //币种

            documentprocess_cc_cdi_titleUP: 'Unit Price(USD)',
            documentprocess_cc_cdi_titleAm: 'Amount(USD)',

            documentprocess_cc_cdi_table_number: '', //数量和
            documentprocess_cc_cdi_table_amount: '', //金额总和

            documentprocess_cc_cdi_table: [
              {
                documentprocess_cc_cdi_products: '',
                documentprocess_cc_cdi_description: '',
                documentprocess_cc_cdi_quantity: '',
                documentprocess_cc_cdi_price: '',
                documentprocess_cc_cdi_lineAmount: ''
              }
            ]

          },

          //报关箱单
          documentprocess_cc_customsDeclarationBox: {
            id: '',
            formInstId: '',
            attachedFiles: [],
            documentprocess_cc_cdb_toName: '',
            documentprocess_cc_cdb_toAdd: '',
            documentprocess_cc_cdb_toTel: '',
            documentprocess_cc_cdb_invoiceNO: '',
            documentprocess_cc_cdb_invoiceDate: '',
            documentprocess_cc_cdb_fromPort: '',
            documentprocess_cc_cdb_toPort: '',
            documentprocess_cc_cdb_shipDate: '',
            documentprocess_cc_cdb_transport: '',
            documentprocess_cc_cdb_payTerms: 'BY T/T',
            documentprocess_cc_cdb_tradeTerms: '',

            documentprocess_cc_cdb_total_quantity: 0,
            documentprocess_cc_cdb_total_netWeight: 0, 
            documentprocess_cc_cdb_total_grossWeight: 0, 
            documentprocess_cc_cdb_total_measurement: 0, 

            documentprocess_cc_cdb_table: [
              {
                documentprocess_cc_cdb_products: '', //产品
                documentprocess_cc_cdb_description: '', //描述
                documentprocess_cc_cdb_quantity: 0, //数量
                documentprocess_cc_cdb_packagenumber: '', //
                documentprocess_cc_cdb_netWeight: 0, //net weight
                documentprocess_cc_cdb_grossWeight: 0, //gross weight
                documentprocess_cc_cdb_measurement: 0 // measurement
              }
            ],

            documentprocess_cc_cdb_totalPackage: 0,
            documentprocess_cc_cdb_totalPackageUnit: 'PKGS',
            documentprocess_cc_cdb_marks: '',
            documentprocess_cc_cdb_shipMarks: ''
          },

          //报关合同委托书
          documentprocess_cc_customsDeclarationContract: {
            id: '',
            formInstId: '',
            attachedFiles: [],
            documentprocess_cc_cdc_contractNO: '', //合同编号
            documentprocess_cc_cdc_contractDate: '', //签订日期
            documentprocess_cc_cdc_buyer: '', //买方
            documentprocess_cc_cdc_buyerAdd: '', //买方地址
            documentprocess_cc_cdc_buyerTel: '', //买方电话
            documentprocess_cc_cdc_description: '', //产品描述
            documentprocess_cc_cdc_quantitys: '', //产品数量
            documentprocess_cc_cdc_quantityUnit: 'PKGS', //产品数量单位
            documentprocess_cc_cdc_amounts: '', //产品金额
            documentprocess_cc_cdc_amounts_usd: 'USD', //金额单位
            documentprocess_cc_cdc_payTerms: '', //付款方式
            documentprocess_cc_cdc_shipDate: '', //装期
            documentprocess_cc_cdc_loadPort: '', //出发港
            documentprocess_cc_cdc_marks: '', //ship marks
            documentprocess_cc_cdc_destPort: '', //目的港
            documentprocess_cc_cdc_otherTerms: '',//other terms
            documentprocess_cc_cdc_insurance: 'TO BE COVERED BY BUYER ', //insurance
          },

          //报关单
          documentprocess_cc_declarationForm: {
            id: '',
            formInstId: '',
            attachedFiles: [], //附件
            documentprocess_cc_df_enterNO: '', //录入编号
            documentprocess_cc_df_hscode: '', //海关编号
            documentprocess_cc_df_company: '', //单位
            documentprocess_cc_df_exportPort: '', //出口口岸
            documentprocess_cc_df_exportDate: '', //出口日期
            documentprocess_cc_df_applyDate: '', //申请日期
            documentprocess_cc_df_transport: '', //运输方式
            documentprocess_cc_df_transportTool: '', //运输工具
            documentprocess_cc_df_delNO: '', //提运单号
            documentprocess_cc_df_recordNO: '', //备案号
            documentprocess_cc_df_tradeCountry: '', //贸易国
            documentprocess_cc_df_destCountry: '', //运抵国
            documentprocess_cc_df_specPort: '', //指运港
            documentprocess_cc_df_yardGoods: '', //境内货源
            documentprocess_cc_df_license: '', //许可证
            documentprocess_cc_df_tradeTerms: '', //成交方式
            documentprocess_cc_df_freight: '', //运费
            documentprocess_cc_df_premium: '', //保费
            documentprocess_cc_df_otherCharge: '', //杂费
            documentprocess_cc_df_contractNO: '', //合同编号
            documentprocess_cc_df_numbers: '', //件数
            documentprocess_cc_df_cartons: 'PKGS', //包装种类
            documentprocess_cc_df_grossWeight: '', //毛重
            documentprocess_cc_df_netWeight: '', //净重
            documentprocess_cc_df_containerNO: '', //集装箱号
            documentprocess_cc_df_attachBills: '', //随附单据
            documentprocess_cc_df_manufacturer: '', //生产厂家
            documentprocess_cc_df_marks: '', //标记
            documentprocess_cc_df_table: [
              {
                  documentprocess_cc_df_productNO: '', //商品编号
                  documentprocess_cc_df_productName: '', //商品名称
                  documentprocess_cc_df_productDesc: '', //商品描述
                  documentprocess_cc_df_quantityAndUnit: [0, '个'], //数量个数 以及 单位
                  documentprocess_cc_df_weightAndUnit: [0, 'KGS'], //重量 以及 单位
                  documentprocess_cc_df_destnationContry: '', //最终运抵国
                  documentprocess_cc_df_price: '', //单价
                  documentprocess_cc_df_amount: '', //总价
                  documentprocess_cc_df_currency: '人民币', //货币
                  documentprocess_cc_df_LevyExemption: '照章', //征免
                  documentprocess_cc_df_countryOrigin: '', //原产国(新添属性)
              }
            ],
              /*新添属性*/
              documentprocess_cc_df_domesticConsignor: '', //境内发货人
              documentprocess_cc_df_exitCustoms: '', //出境关别
              documentprocess_cc_df_recordNumber: '', //备案号
              documentprocess_cc_df_overseasConsignee: '', //境外收货人
              documentprocess_cc_df_conveyanceAndVoyageNumber: '', //运输工具名称及航次号
              documentprocess_cc_df_supervisionMode: '', //监管方式
              documentprocess_cc_df_exemptingNature: '', //征免性质
              documentprocess_cc_df_departurePort: '', //离境口岸
              documentprocess_cc_df_shippingMarks: '', //标记唛码及备注
          },

          //申报要素
          documentprocess_cc_declarationElements: {
            id: '',
            formInstId: '',
            attachedFiles: [], //附件
            documentprocess_cc_de_hscode: '', //海关编码
            documentprocess_cc_de_product: '', //产品
            documentprocess_cc_de_use: '', //用途
            documentprocess_cc_de_brand: '', //品牌
            documentprocess_cc_de_description: '', //型号

            //自定义的字段
            documentprocess_cc_de_def: [
              {
                name: '',
                value: ''
              }, {
                name: '',
                value: ''
              }, {
                name: '',
                value: ''
              }, {
                name: '',
                value: ''
              }, {
                name: '',
                value: ''
              }, {
                name: '',
                value: ''
              }
            ]
          }
      },
      allData: {},
      tabValue: '1',
    }
  },
  watch: {
    datas(newValue, oldValue){
      this.saveData = _.cloneDeep(newValue);
      this.allData = _.cloneDeep(newValue);
    }
  },
  props: {
    datas: {
      type: Object,
      required: true
    },
    editable: {
      type:Boolean,
      required: true
    },
    bus: {
      type: Object,
      required: true
    }
  },
  methods: {

    /**
     * 工厂发货 将最新的数据传递给 最外层组件
     */
    emitToParent(){
      this.$emit("fromDC", "documentprocess_cc", this.allData);
    },

    /**
     * 工厂发货子组件 更新数据
     * @param {String} key 子组件字段
     * @param {Object}  value
     */
    updateData(key, value){
      let temp = _.cloneDeep(this.allData);
      temp[key] = value;
      this.allData = _.cloneDeep(temp);
      this.emitToParent();
    },
     
    documentProcessChoose(current) {
    }
  }
}
</script>

<style scoped lang="scss">
.documentMember-declaring-customsVue{
  box-sizing: border-box;

}
</style>
